package cn.stylefeng.guns.modular.config.service.impl;

import cn.stylefeng.guns.modular.config.entity.Config;
import cn.stylefeng.guns.modular.config.mapper.ConfigMapper;
import cn.stylefeng.guns.modular.config.service.ConfigService;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.stereotype.Service;

@Service
public class ConfigServiceImpl extends ServiceImpl<ConfigMapper, Config> implements ConfigService {

    @Override
    public void edit(Config config) {
        LambdaQueryWrapper<Config> wrapper = createWrapper(config);
        this.update(config, wrapper);
    }

    private LambdaQueryWrapper<Config> createWrapper(Config config) {
        LambdaQueryWrapper<Config> queryWrapper = new LambdaQueryWrapper<>();
        String k = config.getK();
        queryWrapper.eq(Config::getK, k);
        return queryWrapper;
    }
}
